package com.base.vistter.iframe.inverter.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.base.vistter.iframe.bean.Result;
import com.base.vistter.iframe.entity.InverterRelation;
import com.base.vistter.iframe.exception.IframeException;
import com.base.vistter.iframe.service.InverterRelationService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/relation")
public class InverterRelationController {

    @Resource(name = "inverterRelationService")
    private InverterRelationService inverterRelationService;

    @GetMapping
    public Result<InverterRelation> get() throws IframeException {
        LambdaQueryWrapper<InverterRelation> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.last("LIMIT 1");
        return Result.ok(inverterRelationService.selectOne(lambdaQueryWrapper));
    }

}
